<template>
  <div class="app-container">
    <div class="filter-container" >
      <!--<div style="height: 30px;">
        <span>营业汇总表</span>
      </div>-->
      <searchBar @searchEvent= "handleFilter">
        <div slot="one" style="display: inline-block;">
          <el-select v-model="listQuery.discount" placeholder="均价金额" clearable style="width: 120px" class="filter-item">
            <el-option v-for="item in importanceOptions" :key="item.key" :label="item.txt" :value="item.key"/>
          </el-select>
        </div>
      </searchBar>
    </div>
    <div style="height: 50px;margin-top: 20px;padding: 0 12px; background:#eee; line-height: 50px;">
      <span>品牌营业汇总表</span>
      <el-button v-waves style="float: right; margin-top: 7px;" class="filter-item" type="primary" @click="download">月报表</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :key="tableKey"
      :data="overAll"
      __height="550"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="品牌名称" fixed prop="id" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="原价销售总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.originalAmountSum && scope.row.originalAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.orderAmountSum && scope.row.orderAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实收总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.paymentAmountSum && scope.row.paymentAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="优惠总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.discountAmount && scope.row.discountAmount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="退款总额" width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.refundMoneySum && scope.row.refundMoneySum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="人均" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderMoneyPersonAve && scope.row.orderMoneyPersonAve || 0 }}</span>
        </template>
      </el-table-column>

      <el-table-column label="单均" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderMoneyCountAve && scope.row.orderMoneyCountAve || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单总数" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderCount && scope.row.orderCount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="各业务营业数据" align="center" >
        <el-table-column label="堂食总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderTsMoneySum && scope.row.orderTsMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="堂食单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderTsCount && scope.row.orderTsCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外带总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWdMoneySum && scope.row.orderWdMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外带单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWdCount && scope.row.orderWdCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWmMoneySum && scope.row.orderWmMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWmCount && scope.row.orderWmCount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="实收构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.realPaySum && scope.row.realPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="支付宝" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.aliPaySum && scope.row.aliPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="微信" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.weChatPaySum && scope.row.weChatPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.cashPaySum && scope.row.cashPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="银联" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.unionPaySum && scope.row.unionPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="新美大" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.chinaInternetPlusPaySum && scope.row.chinaInternetPlusPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="团购" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.groupBuyingPaySum && scope.row.groupBuyingPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖实收" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.wmPaySum && scope.row.wmPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="浦发75代100" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.userDefined && scope.row.userDefined || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值账户支付" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.accountBalancePaySum && scope.row.accountBalancePaySum || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="优惠构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.discountPayCount && scope.row.discountPayCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="POS折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.posDiscountMoney && scope.row.posDiscountMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="红包" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.redPacketDiscount && scope.row.redPacketDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="线上优惠券" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.onLineDiscountCoupon && scope.row.onLineDiscountCoupon || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="线下代金券" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.offlineVoucher && scope.row.offlineVoucher || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会员折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.memberDiscount && scope.row.memberDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="赠菜" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.grantMoney && scope.row.grantMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.wmDiscountMoney && scope.row.wmDiscountMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值赠送支付" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.chargeGiveMoney && scope.row.chargeGiveMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="招行减20" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderCount && scope.row.orderCount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="退款构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.refundCount && scope.row.refundCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金退款" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.cashRefundMoney && scope.row.cashRefundMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="退菜返还红包" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.returnDishesRedPacket && scope.row.returnDishesRedPacket || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="美食广场" align="center" >
        <el-table-column label="实体卡充值本金支付" align="center" width="150px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardPay && scope.row.cardPay || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡充值赠送支付" align="center" width="150px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardGivePay && scope.row.cardGivePay || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡退款金额" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardRefundMoney && scope.row.cardRefundMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡折扣" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardDiscount && scope.row.cardDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
    </el-table>
    <div style="height: 50px;margin-top: 20px;padding: 0 12px; background:#eee; line-height: 50px;">
      <span>店铺营业汇总表</span>
      <el-button v-waves style="float: right; margin-top: 7px;" class="filter-item" type="primary" @click="download">月报表</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :key="tableKey"
      :data="list"
      height="500"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="店铺名称" fixed prop="id" align="center" >
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="原价销售总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.originalAmountSum && scope.row.originalAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.orderAmountSum && scope.row.orderAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实收总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.paymentAmountSum && scope.row.paymentAmountSum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="优惠总额" fixed width="110px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.discountAmount && scope.row.discountAmount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="退款总额" width="80px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.refundMoneySum && scope.row.refundMoneySum || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="人均" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderMoneyPersonAve && scope.row.orderMoneyPersonAve || 0 }}</span>
        </template>
      </el-table-column>

      <el-table-column label="单均" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderMoneyCountAve && scope.row.orderMoneyCountAve || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="下单总数" align="center" width="80px">
        <template slot-scope="scope">
          <span>{{ scope.row.orderCount && scope.row.orderCount || 0 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="各业务营业数据" align="center" >
        <el-table-column label="堂食总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderTsMoneySum && scope.row.orderTsMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="堂食单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderTsCount && scope.row.orderTsCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外带总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWdMoneySum && scope.row.orderWdMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外带单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWdCount && scope.row.orderWdCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖总额" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWmMoneySum && scope.row.orderWmMoneySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖单数" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderWmCount && scope.row.orderWmCount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="实收构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.realPaySum && scope.row.realPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="支付宝" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.aliPaySum && scope.row.aliPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="微信" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.weChatPaySum && scope.row.weChatPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.cashPaySum && scope.row.cashPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="银联" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.unionPaySum && scope.row.unionPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="新美大" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.chinaInternetPlusPaySum && scope.row.chinaInternetPlusPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="团购" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.groupBuyingPaySum && scope.row.groupBuyingPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖实收" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.wmPaySum && scope.row.wmPaySum || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="浦发75代100" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.userDefined && scope.row.userDefined || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值账户支付" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.accountBalancePaySum && scope.row.accountBalancePaySum || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="优惠构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.discountPayCount && scope.row.discountPayCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="POS折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.posDiscountMoney && scope.row.posDiscountMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="红包" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.redPacketDiscount && scope.row.redPacketDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="线上优惠券" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.onLineDiscountCoupon && scope.row.onLineDiscountCoupon || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="线下代金券" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.offlineVoucher && scope.row.offlineVoucher || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="会员折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.memberDiscount && scope.row.memberDiscount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="赠菜" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.grantMoney && scope.row.grantMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="外卖折扣" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.wmDiscountMoney && scope.row.wmDiscountMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="充值赠送支付" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.chargeGiveMoney && scope.row.chargeGiveMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="招行减20" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.orderCount && scope.row.orderCount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="退款构成" align="center" >
        <el-table-column label="小计" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.refundCount && scope.row.refundCount || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="现金退款" align="center" width="80px">
          <template slot-scope="scope">
            <span>{{ scope.row.cashRefundMoney && scope.row.cashRefundMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="退菜返还红包" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.returnDishesRedPacket && scope.row.returnDishesRedPacket || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="美食广场" align="center" >
        <el-table-column label="实体卡充值本金支付" align="center" width="150px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardPay && scope.row.cardPay || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡充值赠送支付" align="center" width="150px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardGivePay && scope.row.cardGivePay || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡退款金额" align="center" width="120px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardRefundMoney && scope.row.cardRefundMoney || 0 }}</span>
          </template>
        </el-table-column>
        <el-table-column label="实体卡折扣" align="center" width="100px">
          <template slot-scope="scope">
            <span>{{ scope.row.cardDiscount && scope.row.cardDiscount || 0 }}</span>
          </template>
        </el-table-column>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import { fetchList, fetchPv, createArticle, updateArticle } from '@/api/article'
import waves from '@/directive/waves' // Waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

import searchBar from '@/pages/common/searchBar'
import ReportSearchMixin from '@/pages/common/mixin/ReportSearch.js'

export default {
  name: 'Yinshouhuizong',
  components: { searchBar, Pagination },
  directives: { waves },
  mixins: [ReportSearchMixin],
  data() {
    return {
      beginDate: parseTime(new Date().getTime(), '{y}-{m}-{d}'),
      endDate: parseTime(new Date().getTime(), '{y}-{m}-{d}'),
      tableKey: 0,
      overAll: [], // 品牌的总览数据
      list: [], // 下边的列表数据
      total: 0,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        beginDate: parseTime(new Date().getTime(), '{y}-{m}-{d} 00:00:00'),
        endDate: parseTime(new Date().getTime(), '{y}-{m}-{d} {h}:{i}:{s}'),
        discount: 0 // 默认按折前
      },
      importanceOptions: [
        { key: 0, txt: '按折前' },
        { key: 1, txt: '按折后' }
      ],
      overAllUrl: '/service-report/businessReport/listAllReport' // 概览接口地址
      // listUrl: '/service-report/businessReport/listAnalyzeReport' // 列表接口地址
    }
  },
  created() {
    // this.getList()
    this.fetchData()
  },
  methods: {

    download() {

    }

  }
}
</script>
